package org.fight.util.data;

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import com.fight.util.PropertiesUtil;

/**
 * 读取资源文件共同方法
 * 
 * @author dell
 * 
 */
public enum Configuration {
	PROPERTIES;
	private Map<String, String> map = null;
	private Configuration(){
		try {
            /*--------获取properties文件内容------------*/
			PropertiesUtil props = new PropertiesUtil("conf/configuration.properties");
			Set<Object> keyset = props.getPropertie().keySet();  
			map = new HashMap<String, String>();
			for (Object object : keyset) {  
                String propValue = props.getValue(object.toString());  
                map.put(object.toString(), propValue);  
            } 
        } catch (Exception e) {
            e.printStackTrace();
        }
	}
	public Map<String, String> getMap() {
		return map;
	}
	 public static String getConfig(String key) {
	        Properties pros = new Properties();
	        String value = "";
	        try {
	            pros.load(new InputStreamReader(Object.class.getResourceAsStream("/conf/configuration.properties"), "UTF-8"));
	            value = pros.get(key).toString();
	        } catch (IOException e) {
	        	 e.printStackTrace();
	        }
	        return value;
	    }
}
